InternetQueryOption (wininet)
Last changed: -216.107.210.91

.
Summary
Used to query Windows' current Internet proxy settings.

C# Signature:

[DllImport("wininet.dll", SetLastError=true)]
static extern bool InternetQueryOption(IntPtr hInternet, uint dwOption, char[] lpBuffer, ref int lpdwBufferLength);

VB Signature:

<DllImport("wininet.dll", SetLastError:=True)> Shared Function InternetQueryOption(ByVal hInternet As IntPtr, ByVal dwOption As UInteger, ByVal  lpBuffer() As Char, ByRef lpdwBufferLength As Integer) As Boolean

End Function

User-Defined Types:

None.

Notes:

In order to set new proxy settings use InternetSetOption.

Tips & Tricks:

Please add some!

Sample Code:

Retrieve WinInet version in C#:

const int INTERNET_OPTION_VERSION = 40;

[StructLayout(LayoutKind.Sequential)]
public struct INTERNET_VERSION_INFO
{
     public int dwMajorVersion;
     public int dwMinorVersion;
};

// Note that I named the imported fcn "InternetQueryVersion" due to custom arg signature
[DllImport("wininet.dll", EntryPoint = "InternetQueryOption")]
private extern static bool InternetQueryVersion(int Handle, int OptionFlag, ref INTERNET_VERSION_INFO Version, ref int size);

INTERNET_VERSION_INFO Version = new INTERNET_VERSION_INFO();
int size = Marshal.SizeOf(Version);
bool r = InternetQueryVersion(0, INTERNET_OPTION_VERSION, ref Version, ref size);

Alternative Managed API:

Do you know one? Please contribute it!

Documentation

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wininet/wininet/internetqueryoption.asp